<?php

class Form_Account extends Zend_Form
{

    public $buttonDecorators = array(
        'ViewHelper',
        array(array('data' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'block')));

    public function init()
    {
        $this->setMethod(self::METHOD_POST);

        /* this Elements & Other Definitions Here ... */
        $first_name = $this->createElement('text', 'first_name');
        $first_name->setRequired(true);
        $first_name->addFilter('StringTrim');
        $first_name->setLabel('First name');
        $this->addElement($first_name);

        $last_name = $this->createElement('text', 'last_name');
        $last_name->setRequired(true);
        $last_name->addFilter('StringTrim');
        $last_name->setLabel('Last name');
        $this->addElement($last_name);

        //nutno dodelat validator emailove adresy a mozna zauvazovat o tom
        //jestli budeme chtit nejaky potvrzovaci email
        $email = $this->createElement('text', 'email');
        $email->setRequired(true);
        $email->addFilter('StringToLower');
        $email->addFilter("StringTrim");
        $email->addValidator('EmailAddress');
        $email->setLabel('E-mail');
        $this->addElement($email);

        $lastfm = $this->createElement('text', 'last_fm_username');
        $lastfm->addValidator('stringLength', false, array(0, 20));
        $lastfm->setRequired(true);
        $lastfm->addFilter('StringTrim');
        $lastfm->addValidator(new LastFM_ValidateUser());
        $lastfm->setLabel('Last.fm account');
        $this->addElement($lastfm);

        $locale = $this->createElement('select', 'locale');
        $locale->setLabel('Language');
        $locale->setRequired(true);
        $locale->addMultiOptions(array('cs' => 'czech', 'en' => 'english'));
        $this->addElement($locale);

        $autoplay = $this->createElement('checkbox', 'autoplay');
        $autoplay->setLabel('Autoplay');
        $autoplay->addFilter('Int');
        $this->addElement($autoplay);


        $button = $this->createElement('button', 'Register_button', array("label" => "Save", "type" => "submit", "class" => "thoughtbot", "decorators" => $this->buttonDecorators));
        $this->addElement($button);
    }

}